const MiniCssExtractPlugin = require("mini-css-extract-plugin")
const CopyWebpackPlugin = require('copy-webpack-plugin')
const config = require('./../config')
const {resolve} = require('path')
const r = path => resolve(__dirname, path)
module.exports = {
    output:{
        path:config.assetsPath,
        filename:'[name].js'
    },
    resolve:{
        alias:{
            utils:r('../utils/utils')
        }
    },
    module:{
        rules:[
            {
                test:/\.js$/,
                loader:'babel-loader',
                exclude:/node_modules/,
            },
            {
                test:/\.(sass|scss|css)$/,
                test: /\.scss$/,
                use: [
                    MiniCssExtractPlugin.loader,
                    "css-loader",
                    "sass-loader"
                ]
            },
            {
                test: /\.mina$/,
                loader: 'wechat-mina-loader'
            }
        ]
    },
    plugins: [
        new MiniCssExtractPlugin({
            filename: "[name].css",
            chunkFilename: "[id].css"
        }),
        new CopyWebpackPlugin([{
            from:'pages/**/*.json',
            to:''
        },{from:'static',to:'static'}])
    ]
}
